<?php

declare(strict_types=1);

namespace Modules\Purchasing\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $warehosnumber
 * @property $state
 * @property $remark
 * @property $writestate
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class Purchasewarehousing extends Model
{
    

    protected $table = 'purchasewarehousing';

    protected $fillable = [ 'id', 'warehosnumber', 'state', 'remarks', 'writestate', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ,'modifier','incomingtype','fbillno','fpurchaseorgid_number','fpurchaseorgid_name','fsupplierid_number','fsupplierid_name','fprovidercontactid','fproviderphone','fid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $fields = ['id','warehosnumber','state','remarks','writestate','created_at','updated_at','modifier','incomingtype','fbillno','fpurchaseorgid_number','fpurchaseorgid_name','fsupplierid_number','fsupplierid_name','fprovidercontactid','fproviderphone','fid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $form = ['id','warehosnumber','state','remarks','writestate','created_at','updated_at','modifier','incomingtype','fbillno','fpurchaseorgid_number','fpurchaseorgid_name','fsupplierid_number','fsupplierid_name','fprovidercontactid','fproviderphone','fid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    
    /**
     * @var array
     */
    public array $searchable = [
        'warehosnumber' => 'like',
        'remarks' => 'like',
        'state' => '=',
        'incomingtype' => '=',
        'writestate' => '=',
    ];
    
    //输出相应的时间格式
    protected function serializeDate($date)
    {
        return $date->format('Y-m-d H:i');
    }

     /**
     * 链表查询
     */
    public function detailscheckOne()
    {
        return $this->hasOne(PurchasewarehousingDetail::class);//查一条
    }

    public function detailscheckAll()
    {
        return $this->hasMany(PurchasewarehousingDetail::class);//查多条
    }

    public function detailscheckAllMateriel()
    {
        return $this->hasMany(PurchasewarehousingMateriel::class);//查多条
    }


    
}
